import { get, post } from "./base";


export interface TbFirmType {
    id: number,
    name: string,
    description: string,
    version: number,
    ty: string,
    target: string,
}

export const FILM_TYPE_BIN = "bin";
export const FILM_TYPE_HEX = "hex";
export const FILM_TYPE_BOOTLOADER_HEX = "bootloader_hex";

export const FIRM_TYPE_TYS = [
    FILM_TYPE_BIN,
    FILM_TYPE_HEX,
    FILM_TYPE_BOOTLOADER_HEX,
    "apk",
    "exe",
    "unknown",
];

export async function queryFirmType(id: number) {
    const resp = await get(`/firm_type/query?proj_id=${id}`);
    return await resp.parse<TbFirmType[]>();
}

interface CreateReq {
    proj_id: number,
    name: string,
    description: string,
    version: number,
    ty: string,
    target: string,
}

export async function createFirmType(req: CreateReq) {
    await post('/firm_type/create', req);
}

export async function deleteFirmType(id: number) {
    await post('/firm_type/delete', id);
}




